package com.xxg.fileshand.app;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;

import com.blankj.utilcode.util.CrashUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.Utils;
import com.xxg.fileshand.crash.CrashHandler;


/**
 * Create by Sxl on 2021/12/21.
 */
public class App extends Application {

    private static Context instance;
    public static Context getContext() {
        return instance;
    }

    public static String token = "";
    public static int nStaffID = 0;
    public static String userName = "";

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        Utils.init(this);

//        LogUtils.getConfig().setDir(FileUtil.getBaseDir(this) + "/Log");
        LogUtils.getConfig().setLog2FileSwitch(true);
        CrashUtils.init();
//        initCrash();
    }


    /**
     * 初始化崩溃日志crash
     */
    private void initCrash() {
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(this);
    }

    /**
     * 重写 getResource 方法，防止系统字体影响
     */
    @Override
    public Resources getResources() {//禁止app字体大小跟随系统字体大小调节
        Resources resources = super.getResources();
        if (resources != null && resources.getConfiguration().fontScale != 1.0f) {
            android.content.res.Configuration configuration = resources.getConfiguration();
            configuration.fontScale = 1.0f;
            resources.updateConfiguration(configuration, resources.getDisplayMetrics());
        }
        return resources;
    }

}
